export const baseInfoFormRules = {
  name: [
    { required: true, message: '请输入产品名称', trigger: 'blur' },
  ],
  code: [
    { required: true, message: '请输入产品编码', trigger: 'blur' },
  ],
  type: [
    { required: true, message: '请选择类别', trigger: 'change' },
  ],
  brand: [
    { required: true, message: '请选择经营品牌', trigger: 'change' },
  ],
  manufacturer:[
    { required: true, message: '请输入生产厂家', trigger: 'blur' },
  ],
  executiveStandard:[
    { required: true, message: '请输入执行标准', trigger: 'blur' },
  ],
  imgs: [
    { required: true, message: '请上传产品图片', trigger: 'change' },
  ],
  salesStatus: [
    { required: true, message: '请选择销售状态', trigger: 'change' },
  ],
  salesClassification:[
    { required: true, message: '请选择销售分类', trigger: 'change' },
  ],
  mnemonicCode:[
    { required: true, message: '请输入助记码', trigger: 'blur' },
  ],
  retailPrice:[
    { required: true, message: '请输入零售价', trigger: 'blur' },
  ]
}

export const mallInfoFormRules = {
  allowMall:[
    { required: true, message: '请选择是否允许上架', trigger: 'change' },
  ],
  pickType:[
    { required: true, message: '请选择配送方式', trigger: 'change' },
  ],
  mallPlatformFee:[
    { required: true, message: '请输入商品平台服务费', trigger: 'change' },
  ]
  // detail:[
  //   { required: true, message: '请输入产品详情', trigger: 'blur' },
  // ]
}

export const wholesaleInfoFormRules = {
  wholesaleStatus:[
    { required: true, message: '请选择批发状态', trigger: 'change' },
  ],
  wholesalePrice:[
    { required: true, message: '请输入批发价', trigger: 'blur' },
  ],
  wholesaleClass:[
    { required: true, message: '请选择批发分类', trigger: 'change' },
  ],
  // detail:[
  //   { required: true, message: '请输入产品详情', trigger: 'blur' },
  // ],
  minimumOrderQuantity:[
    { required: true, message: '请输入最小起订量', trigger: 'blur' },
  ]
}


// 最低售价校验规则
export const minSalePriceRules = (maxNumber) => [
  {
    required:true,
    validator:(rules,value,callback) => {
      if(!value){
        callback(new Error('最低售价不能为空'))
      }else if(value < 0.01 || value > +maxNumber ){
        callback(new Error('最低售价需大于等于0.01，小于等于零售价'))
      }else{
        callback()
      }
      
    },
    trigger: 'blur'
  }
]